#include "ProviderImage.h"

#include "core/AppSignals.h"

ProviderImage::ProviderImage()
    : PropertyProvider()
{
}

void ProviderImage::initEditor(
    QtTreePropertyBrowser* editor,
    shared_ptr<BaseElement> entity
)
{
    entity_ = dynamic_pointer_cast<uml::Image>(entity);
    propertyToId.clear();
    PropertyProvider::initEditor(editor, entity);

    addProperty("content", "content", entity_->content());
    addProperty("format", "format", entity_->format());
    addProperty("location", "location", entity_->location());

}

void ProviderImage::valueChanged(QtProperty* property, bool value)
{
    QString id = propertyToId[property];
    
}

void ProviderImage::valueChanged(QtProperty* property, double value)
{
    QString id = propertyToId[property];
    
}

void ProviderImage::valueChanged(QtProperty* property, int value)
{
    QString id = propertyToId[property];
    
}

void ProviderImage::valueChanged(QtProperty* property, QString value)
{
    QString id = propertyToId[property];
    if (id == "content") {
        entity_->setContent(value);
        emit appSignals->onElementChanged(this, entity_);
    } else if (id == "format") {
        entity_->setFormat(value);
        emit appSignals->onElementChanged(this, entity_);
    } else if (id == "location") {
        entity_->setLocation(value);
        emit appSignals->onElementChanged(this, entity_);
    }
}
